<?php
class Session {
/// definition and constructor ///
	var $sess_mc;
	var $sess_life = 86400; // 86400 = 1天
	function Session() {
		$this->__construct();
	}
	function __construct() {
		/** session_set_save_handler(
			array(&$this, "open"),
			array(&$this, "close"),
			array(&$this, "read"),
			array(&$this, "write"),
			array(&$this, "destroy"),
			array(&$this, "gc")
		);*/
		ini_set('session.save_path', __PHY_TMP.'/sess');
		session_name("sess_work");
		session_start();
	}
	function __destruct() {
		;
	}

/// handler ///
	function open($save_path, $session_name) {
		$this->sess_mc = connectMemcacheCluster('session');
	    return true;
	}
	function close() {
		$this->sess_mc->close();
	    return true;
	}
	function read($key) {
	    return $this->sess_mc->get($key);
	}
	function write($key, $val) {
	    return $this->sess_mc->set($key, $val, 0, $this->sess_life);
	}
	function destroy($key) {
	    return $this->sess_mc->delete($key);
	}
	function gc($maxlifetime) {
	    return TRUE;
	}
}
?>
